<?php
echo '<div id="ViewNav">Month View | List View</div>
<div id="CalendarNav"><a href="'.GetUrl($this->Context->Configuration, 'extension.php', '', 'PostBackAction', 'Vcal' ,'',$this->Uri->prev($this->Month, 'month')).'">'.Calendar_Util_Textual::prevMonthName($this->Month,'long').'</a> | '. Calendar_Util_Textual::thisMonthName($this->Month,'long').' | <a href="'.GetUrl($this->Context->Configuration, 'extension.php', '', 'PostBackAction', 'Vcal' ,'',$this->Uri->next($this->Month, 'month')).'">'. Calendar_Util_Textual::nextMonthName($this->Month,'long').'</div>';

echo'<div id="MonthView">
<table class="calendar" width="100%" cellspacing="0" cellpadding="0">';


$i = 0;
while ($Day = $this->MonthDecorator->fetch()) {
    
    if ($Day->isFirst()) {
        echo "<tr>\n";
    }

    echo '<td class="calCell';
    if ($Day->isSelected()) {
        echo ' calCellBusy';
    } elseif ($Day->isEmpty()) {
        echo ' calCellEmpty';
    }
    if ($Day->thisDay() == date('j') && $Day->thisMonth() == date('m')) {
        echo ' Today';
    }
    echo '">';
    if (($i == 0 && $Day->thisDay() != 1) || $Day->thisDay() == 1) {
        $MonthClass = 'Month'.$Day->thisMonth();
    }
    else {
        $MonthClass = '';
    }
    if ($i < 7) {
        $DayName = $this->DayNames[$i];
    }
    else {
        $DayName = '';
    }
    if ($Day->thisDay() == date('j')) {
        $Today = 'Today';
    }
    else {
        $Today = '';
    }
    echo '<div class="dayNumber '.$MonthClass.'" >'.$DayName.' '. $Day->thisDay().'</div>';
    $i++;
    if ($Day->isEmpty()) {
        echo '&nbsp;';
    } else {
        echo '<div class="dayContents"><ul>';
        while ($entry = $Day->getEntry()) {
            echo  '<li class="'.$entry['Title'].'" style="background-color:'.$entry['Color'][0].';border:1px solid '.$entry['Color'][1].';">                    
                    <span class="Time" style="color:'.$entry['Color'][3].';">'.date("g:i a",strtotime($entry['Start'])).'</span> <a style="color:'.$entry['Color'][2].'" href="'.$entry['Link'].'">'.$entry['Name'].'</a>
                   </li>';
        }
        echo '</ul><br /></div>';
    }
    echo '</td>';

    if ($Day->isLast()) {
        echo "</tr>\n";
    }
}
echo'</table></div>';
?>
